package com.jt.system.controller;

import com.jt.system.pojo.User;
import com.jt.system.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author 金帮嘉诚 @date 2021-08-31 星期二 16:58
 */
@RestController
@RequestMapping("/user/")
public class Usercontroller {
    @Autowired
    private UserService userService;//依赖于接口 门面模式

    @GetMapping("login/{username}")
    public User getUserByUsername(@PathVariable("username") String username) {
        return userService.selectUserByUsername(username);
    }

    @GetMapping("permission/{userId}")
    public List<String> listUserPermissions(@PathVariable("userId") Long userId) {
        return userService.selectUserPermissions(userId);
    }

}
